package com.yzi.core.schedule
{
	import com.yzi.core.IObservable;
	
	import flash.events.Event;
	
	public class Report implements IReport
	{
		private var m_observerList:Vector.<IObservable>;
		private var m_result:*;
		
		public function Report()
		{
			init();
		}
		
		private function init(): void
		{
			m_observerList = new Vector.<IObservable>();
		}
		
		public function AddObserver($observer:IObservable):void
		{
			m_observerList.push($observer);
		}
		
		public function RemoveObserver($observer:IObservable):void
		{
			var index:int = m_observerList.indexOf($observer);
			if(index < 0) throw new Error("Out of Index");
			m_observerList.splice(index, 1);
		}
		
		public function Notify($event:Event=null):void
		{
			for each(var observer:IObservable in m_observerList)
			{
				observer.Update($event);
			}
		}
		
		public function GetResult():* { return m_result; }
		
		public function SetResult($result:*):void { m_result = $result; }
		
		public function Destory():void
		{
			if(m_observerList) m_observerList.length = 0;
			m_observerList = null;
			m_result = null;
		}
	}
}